<style scoped>
.com-wapper{
  width:100%;
  height:36px;
  line-height:36px;
  position: relative;
}

.com-box{
  width:100%;
  height:36px;
  line-height:36px;
  display: flex;
  align-items: center;
}

.com-box.disable{
  opacity: 0.3;
}

.active-box{
  width:15px;
  height:15px;
  line-height:15px;
  text-align:center;
  border:1px solid #FFF;
  color:#FFF;
  cursor: pointer;
}

.label{
  font-size:12px;
  color:#FFF;
  margin-left:7px;
}

.able-mask{
  position: absolute;
  top:0px;
  left:0px;
  width:100%;
  height:100%;
}

.com-input{
  width:240px;
  height:20px;
  line-height:20px;
  border-radius: 3px;
  border:1px solid #FFF;
  padding:0px 3px;
  margin-left:15px;
  background-color: transparent;
  color:#FFF;
  margin-left:auto;
  margin-right:50px;
}
</style>
<template>
<div class="com-wapper">
  <div class="com-box" :class="{'disable':!enable}">
    <div class="active-box" @click="ableHandle">{{enable?'√':''}}</div>
    <div class="label">
      {{label}}
    </div>
    <input type="text" class="com-input" :value="value" @input="$emit('input',$event.target.value)">
    <div class="com-unit">{{unit}}</div>
  </div>
  <div class="able-mask" @click="ableHandle" v-if="!enable"></div>
</div>
</template>
<script>
export default {
  props: {
    label: {
      type: String,
      default: '设置项'
    },
    value: {
      type: [String, Number]
    },
    unit: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      dataCache: ''
    }
  },
  computed: {
    enable () {
      return !(typeof this.value === 'undefined' || this.value === null)
    }
  },
  methods: {
    // ableHandle
    ableHandle () {
      if (this.enable) {
        this.dataCache = this.value
        this.$emit('input', null)
      } else {
        this.$emit('input', this.dataCache)
      }
    }
  }
}
</script>
